package YZ.Students.Mier.controller.web;

import YZ.Students.Mier.Listener.ThymeleafListener;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.WebContext;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @className: PublishServlet
 * @author: shuishui
 * @date: 2022/12/10 16:43
 */
@WebServlet("/static/static/discuss-publish.html")
public class PublishServlet extends HttpServlet{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletContext servletContext = req.getServletContext();
        TemplateEngine templateEngine = ThymeleafListener.getTemplateEngine(servletContext);
        WebContext webContext = new WebContext(req, resp, servletContext);
        templateEngine.process("view/site/discuss-publish", webContext, resp.getWriter());
    }
}
